﻿@using Allin.Abp.AspNetCore.Components.Web.AntDesignTheme.Navigation

<AuthorizeView>
    <Authorized>
        <Dropdown>
            <Overlay>
                <Menu>
                    @for (var i = 0; i < UserMenu.Items.Count; i++)
                    {
                        var item = UserMenu.Items[i];

                        var customComponentType = item.GetComponentTypeOrDefault();

                        if (i == UserMenu.Items.Count - 1) // If last element
                        {
                            <MenuDivider />
                        }

                        if (customComponentType != null)
                        {
                            <DynamicComponent Type="@customComponentType" />
                        }
                        else
                        {
                            <MenuItem>
                                <a href="@item.Url.TrimStart('/', '~')" target="@item.Target" id="@item.ElementId" class="ant-dropdown-item-link">
                                    <span class="lpx-menu-item-icon">
                                        <i class="lpx-icon @item.Icon" />
                                    </span>
                                    <span>
                                        @item.DisplayName
                                    </span>
                                </a>
                            </MenuItem>
                        }
                    }
                </Menu>
            </Overlay>
            <ChildContent>
                <span class="ant-dropdown-link" style="padding:0">
                    @if (TenantName.IsNullOrEmpty())
                    {
                        <span class="user-full-name">@UserFullName</span>
                    }
                    else
                    {
                        <span class="user-full-name"><i>@CurrentTenant.Name</i>\@UserFullName</span>
                    }
                    <Icon Type="down" />
                </span>
            </ChildContent>
        </Dropdown>
    </Authorized>
    <NotAuthorized>
        <a class="nav-link" href="Account/Login">@L["Login"]</a>
    </NotAuthorized>
</AuthorizeView>